﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Salient.SqlServer.Management;

namespace Salient.SqlServer.Tests
{
    [TestFixture]
    public class SqlCmdRunnerConnectionStringFixture
    {
        private const string CString01 = "Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True";
        private const string CString01A = "Initial Catalog=AdventureWorks;Data Source=(local);Integrated Security=True";
        private const string CString02 = "Data Source=(local);Initial Catalog=AdventureWorks;User ID=sa;Password=password";
        [Test]
        public void Test()
        {
            var db = new SqlCmdRunner { ConnectionString = CString01A };
            Assert.AreEqual(CString01, db.ConnectionString);
            Assert.AreEqual("(local)", db.DataSource);
            Assert.AreEqual("AdventureWorks", db.InitialCatalog);
            Assert.AreEqual(true, db.IntegratedSecurity);
            Assert.AreEqual("", db.Password);
            Assert.AreEqual("", db.UserID);
        }
        [Test]
        public void Test1()
        {
            var db = new SqlCmdRunner { ConnectionString = CString02 };
            Assert.AreEqual(CString02, db.ConnectionString);
            
        }

        [Test]
        public void Test3()
        {
            var db = new SqlCmdRunner();
            db.IntegratedSecurity = true;
            db.DataSource = "(local)";
            db.InitialCatalog = "AdventureWorks";
            Assert.AreEqual(CString01, db.ConnectionString);
        }

        [Test]
        public void Test5()
        {
            var db = new SqlCmdRunner();
            db.UserID = "sa";
            db.Password = "password";
            db.DataSource = "(local)";
            db.InitialCatalog = "AdventureWorks";
            Assert.AreEqual(CString02, db.ConnectionString);
        }



    }
}
